#pragma once

unsigned char CalculateChecksum(char* buf, int bufsize)
{
	if (buf && (bufsize>=6))
	{
		unsigned int sum{0};
		for (int i = 0; i < 6; ++i)
			sum += buf[i];
		return sum & 0xFF;
	}
	return 0;
}

void ResetBuf(char* buf, int bufsize=8)
{
	if (buf)
	{
		memset(buf,0, bufsize);
		buf[0] = 0xea;
		buf[1] = 0x08;
		buf[7] = 0xeb;
	}
}